package com.evil.application.service;

import com.baomidou.mybatisplus.extension.service.IService;
import com.evil.application.pojo.dto.ApplicationReqDTO;
import com.evil.application.pojo.dto.ReorderApplicationReqDTO;
import com.evil.application.pojo.entity.ApplicationInfo;
import com.evil.application.pojo.entity.ApplicationPackage;
import com.evil.application.pojo.entity.PackageApplication;
import com.evil.common.application.dto.pkg.ModifyPackageApplicationSourceDTO;
import com.evil.common.application.dto.pkg.PackageApplicationSourceDTO;
import com.evil.common.application.dto.pkg.PackageApplicationSourcesDTO;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;

import java.util.List;
import java.util.Map;

/**
 * 应用包应用表
 *
 * @author liyang
 * @date 2022-08-08 00:00
 */
public interface PackageApplicationService extends IService<PackageApplication> {

    /**
     * 获取应用包应用列表
     *
     * @param packageId packageId
     * @return list
     */
    List<PackageApplication> findByPackageId(Long packageId);

    /**
     * 修改应用/组挂载到应用包
     *
     * @param modifyPackageApplicationSourceDTO modifyPackageApplicationSourceDTO
     */
    void savePackageApplications(ModifyPackageApplicationSourceDTO modifyPackageApplicationSourceDTO);

    /**
     * 获取应用挂载应用包 列表
     *
     * @param sourceDTO sourceDTO
     * @return List
     */
    List<PackageApplication> findBySource(PackageApplicationSourceDTO sourceDTO);

    /**
     * 获取应用包idsMap
     *
     * @param sourcesDTO sourcesDTO
     * @return List
     */
    Map<Long, List<Long>> findPackageIdsMapBySources(PackageApplicationSourcesDTO sourcesDTO);

    /**
     * 新增应用与包关联
     *
     * @param applicationPackage applicationPackage
     * @param applicationInfo    applicationInfo
     */
    void addPackageApp(ApplicationPackage applicationPackage, ApplicationInfo applicationInfo);

    /**
     * 应用包应用列表
     *
     * @param applicationReqDTO applicationReqDTO
     * @return PackageApplication list
     */
    List<PackageApplication> findByApplicationReqDTO(ApplicationReqDTO applicationReqDTO);

    /**
     * 删除应用包应用
     *
     * @param sourceDTO sourceDTO
     */
    List<PackageApplication> deletePackageApplication(PackageApplicationSourceDTO sourceDTO);

    /**
     * 重新排序应用包应用
     *
     * @param reorderApplicationReqDTO reorderApplicationReqDTO
     */
    void reorderApplication(@Validated @RequestBody ReorderApplicationReqDTO reorderApplicationReqDTO);

    /**
     * 获取应用包应用 map
     *
     * @param packageId packageId
     * @return Map
     */
    Map<Integer, Map<Long, PackageApplication>> findMapByPackageId(Long packageId);
}
